#ifndef _EPD_H_
#define _EPD_H_

#include "epd_port.h"
#include "esp_err.h"
#include <stdint.h>

enum
{
    EPD_BLACK = 0x00,
    EPD_WHITE = 0x01,
    EPD_YELLOW = 0x02,
    EPD_RED = 0x03,
    EPD_BLUE = 0x05,
    EPD_GREEN = 0x06,
    EPD_CLEAN = 0x07,
};

typedef enum
{
    EPD_STS_NONE = 0,
    EPD_STS_BUSY,
    EPD_STS_READY,
    EPD_STS_SLEEP,
} epd_status_t;

typedef struct
{
    uint16_t width;
    uint16_t height;
    uint8_t *dis_buf;
    size_t dis_buf_size;
    epd_port_t *port;
    epd_status_t status;
} epd_handle_t;

esp_err_t epd_init(epd_handle_t *handle);
esp_err_t epd_init_fast(epd_handle_t *handle);
esp_err_t epd_sleep(epd_handle_t *handle);
esp_err_t epd_wake(epd_handle_t *handle);
esp_err_t epd_flush(epd_handle_t *handle);

esp_err_t epd_reset(epd_handle_t *handle);
esp_err_t epd_wait_for_idle(epd_handle_t *handle);
esp_err_t epd_write_cmd(epd_handle_t *handle, uint8_t cmd);
esp_err_t epd_write_byte(epd_handle_t *handle, uint8_t data);
esp_err_t epd_write_data(epd_handle_t *handle, uint8_t *data, size_t len);
esp_err_t epd_fill_screen(epd_handle_t *handle, uint8_t color);
esp_err_t epd_clear(epd_handle_t *handle);
esp_err_t epd_dis_pic(epd_handle_t *handle, const uint8_t *data);
esp_err_t epd_dis_e6_file(epd_handle_t *handle, const char *filename);

#endif /* _EPD_H_ */
